package com.zhouyer.study.logindemo.config;

import com.zhouyer.study.logindemo.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 登录拦截拦截配置
 *
 * @author zhouyao
 * @version 1.0
 * @date 2021/9/20 2:00 下午
 */
@Configuration
public class LoginConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        LoginInterceptor loginInterceptor = new LoginInterceptor();
        // 注册登录拦截器
        InterceptorRegistration interceptorRegistration = registry.addInterceptor(loginInterceptor);
        interceptorRegistration.addPathPatterns("/**").excludePathPatterns("/login/**","/doLogin/**", "/error");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
